<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script>
    window.onload = () => {
        if ('WebSocket' in window) {
            // 创建websocket连接
            let ws = new WebSocket('ws://116.62.40.124:8081/u/websocket/message?token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZGVudGl0eSI6ImdvbmdjYWlodWExOTk5IiwiZW1haWwiOiJnb25nY2FpaHVhMTk5OSJ9.2NIr1HEla_qSP6B2emmQ9NV5jNG-RksFrKKkQzn7UvE');
            // 成功连接的时候推送一条消息，此时服务端就可以开始推送数据了
            ws.onopen = () => {
                console.log('websocket success---');
                   ws.send("{\"room_id\":\"58dc0b6ec3474835a947e12f89ac6fb2\",\"content\":\"gongcaihua\",\"type\":1}");
            }
            ws.onmessage = (message) => {
                let data = message.data;
                console.log('get websocket message---', data);
              //  socket.send("{\"room_id\":\"58dc0b6ec3474835a947e12f89ac6fb2\",\"content\":\"gongcaihua\",\"type\":1}");
            }
            ws.onerror = () => {
                console.error('websocket fail');
            }
        } else {
            console.error('dont support websocket');
        };
    };
</script>

</head>
<body>
  
</body>
</html>